package com.example.project22_editingmediaplayer.adapter;

import java.util.ArrayList;

import com.example.project22_editingmediaplayer.R;
import com.example.project22_editingmediaplayer.objects.listalbumObject;



import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterListOfAlbum extends BaseAdapter{
	ArrayList<listalbumObject> datas;
	LayoutInflater inflater;
	Context context;
	public AdapterListOfAlbum(ArrayList<listalbumObject> datas,Context context){
		this.datas = datas;
		this.context = context;
		inflater =(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
      // so luong du lieu
		return datas.size();
	}

	@Override
	public Object getItem(int postion) {
         //lay du lieu o mot vi tri nao day trong mang arraylist    
		return datas.get(postion);
	}

	@Override
	public long getItemId(int arg0) {

		return 0;
	}

	@Override
	public View getView(int postion, View contentView, ViewGroup root) {
		contentView =	inflater.inflate(R.layout.row_playlist_album, root, false);
		
	final	listalbumObject classObject = datas.get(postion);
		// gan ten vao trong control textview dc dinh nghia trong layout contact_row
		TextView tvName = (TextView)contentView.findViewById(R.id.tv_rowplaylistalbum);
		ImageView img_logo = (ImageView)contentView.findViewById(R.id.logo_oflist);
		tvName.setText(classObject.getName_of_playlistalbum());
		img_logo.setBackgroundResource(classObject.getName_of_img());
		
	
		
		
		
		
		return contentView;
	}

}
